<?php
class Adminmodel extends CI_Model {

	function __construct()
	{
		parent::__construct();
	}

	public function init(){
		$dbHandle = $this->load->database('artdex', TRUE);
		if($dbHandle == ''){
			//error_log('can not create db handle','dialdex');
			echo (print_r($dbHandle,true));
		}
		return $dbHandle;
	}

	public function authenticate($post)
	{
		$dbHandle = $this->init();
		$username=$post['username'];
		$password=$post['password'];
		if(isset($post['super'])){
			$type = $post['super'];
		}
		if(isset($post['admin'])){
			$type = $post['admin'];
		}
		$query = "SELECT * FROM art_admin where admin_username='$username' and admin_password='$password' and admin_type='$type' and admin_status='Yes'";
		error_log('hh   '.$query);
		$result = mysql_query($query);
		$userArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result)){
			$userArray[$i] = $row;
			$i++;
		}
		return $userArray;
	}

	public function getAdminPass($adminId)
	{
		$dbHandle = $this->init();
		$query = "select admin_password from art_admin where admin_id='$adminId'";
		error_log('hello  '.$query);
		$result = mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}



	public function getAllAdmin()
	{
		$dbHandle = $this->init();
		$query = "select * from art_admin a, newuser n where a.admin_id=n.admin_id order by a.admin_username";
		$result = mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result)){
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;
	}

	public function userDetailById($aId)
	{
		$dbHandle = $this->init();
		$query = "select * from art_admin a, newuser n where a.admin_id=n.admin_id and a.admin_id='$aId'";
		//error_log('kjgh  '.$query);
		$result = mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}
	public function updateChangePass($post, $adminId)
	{
		$dbHandle=$this->init();
		$userpass=$post['newpass'];
		$query = "update art_admin set admin_password='$userpass' where admin_id='$adminId'";
		error_log('query is     '.$query);
		$result = mysql_query($query);
		return $result;


	}
	
	public function editCategory()
	{
		$dbHandle = $this->init();
		$query = "select * from art_category";
		$result = mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result)){
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;


	}
	public function deleteCategoryById($aid)
	{
		$dbHandle=$this->init();
		$query="delete from art_category where cat_id ='$aid'";
		$result=mysql_query($query);
		$query1="delete from art_cat_theme_medium where cat_id='$aid'";
		$result1=mysql_query($query1);
		$query2="delete from art_category where cat_id='$aid'";
		$result2=mysql_query($query2);
		$query3="delete from art_cat_theme where cat_id='$aid'";
		$result3=mysql_query($query3);
	}
	public function getCategoryById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT * FROM art_category where cat_id='$cId'";
		error_log('hi   '.$query);
		$result=mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}
	public function categoryUpdate($post)
	{
		$dbHandle = $this->init();
		$aid=$post['categoryID'];
		$categoryname = $post['categoryName'];
		$update = "update art_category set name='".$categoryname."' where Cat_id='$aid'";
		$updateresult = mysql_query($update);
	}
	public function insertCategory($post)
	{
		$dbHandle=$this->init();
		$categoryName=$post['categoryName'];
		if($categoryName!=''){
		$h1="INSERT INTO art_category (name)VALUES('$categoryName')";
		error_log('ffffff '.$h1);
		$result=mysql_query($h1) or die(mysql_error());
		}
	}
	public function selectCategoryById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT at.*, ac.* FROM art_theme at, art_category ac, art_cat_theme act where ac.cat_id='$cId' AND act.cat_id=ac.cat_id AND at.theme_id=act.theme_id ";
		error_log('theme   '.$query);
		$result=mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result))
		{
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;
	}

	public function insertTheme($post)
	{
		$dbHandle=$this->init();
		$themeName=$post['themeName'];
		$categoryID=$post['categoryID'];
		$h1="INSERT INTO art_theme (theme_name)VALUES('$themeName')";
		error_log('ffffff '.$h1);
		$result=mysql_query($h1) or die(mysql_error());
		$themeID= mysql_insert_id();
		$h2="INSERT INTO art_cat_theme (cat_id,theme_id)VALUES('$categoryID','$themeID')";
		error_log('fffffflll '.$h2);
		$result1=mysql_query($h2) or die(mysql_error());
			
			
	}
	public function manageTheme()
	{
		$dbHandle = $this->init();
		$query = "select * from art_theme";
		$result = mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result)){
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;


	}
	public function deleteThemeById($aid)
	{
		$dbHandle=$this->init();
		$query="delete from art_theme where theme_id ='$aid'";
		$result=mysql_query($query);
			
		$dbHandle=$this->init();
		$query1="delete from art_cat_theme where theme_id ='$aid'";
		$result1=mysql_query($query1);
		
		$dbHandle=$this->init();
		$query2="delete from art_cat_theme_medium where theme_id='$aid'";
		$result2=mysql_query($query2);
	}

	public function getthemeById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT a_t.*, ac.* FROM art_cat_theme act, art_theme a_t, art_category ac where a_t.theme_id='$cId' AND act.theme_id=a_t.theme_id AND ac.cat_id=act.cat_id";
		error_log('hi theme   '.$query);
		$result=mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}
	function themeUpdate($post)
	{
		$dbHandle = $this->init();
		$aid=$post['themeID'];
		$cid=$post['categoryName'];
		$themename = $post['themeName'];
		$update = "update art_theme set theme_name='".$themename."' where theme_id='$aid'";
		$updateresult = mysql_query($update);
		$delete = "DELETE FROM art_cat_theme WHERE theme_id = '$aid'";
		$deleteResult = mysql_query($delete);
		$insert = "insert into art_cat_theme (cat_id, theme_id) values ($cid, $aid)";
		$insertResult = mysql_query($insert);
	}
		
	

	public function insertMedium($post)
	{
		$dbHandle=$this->init();
		$themeName=$post['mediumName'];
		$categoryID=$post['categoryID'];
		$themeID=$post['themeID'];
		$h1="INSERT INTO art_medium (medium_name)VALUES('$themeName')";
		error_log('ffffff '.$h1);
		$result=mysql_query($h1) or die(mysql_error());
		$mediumID= mysql_insert_id();
		$h2="INSERT INTO art_cat_theme_medium (cat_id,theme_id,medium_id)VALUES('$categoryID','$themeID','$mediumID')";
		error_log('fffffflll '.$h2);
			
		$result1=mysql_query($h2) or die(mysql_error());


	}

	public function manageMedium()
	{
		$dbHandle = $this->init();
		$query = "select * from art_medium";
		$result = mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result)){
			$resultArray[$i] = $row;
			$i++;
		}
//		print_r($resultArray);
//		die();
		return $resultArray;


	}
	public function deleteMediumById($aid)
	{
		$dbHandle=$this->init();
		$query="delete from art_medium where medium_id ='$aid'";
		$result=mysql_query($query);
		$query1="delete from art_cat_theme_medium where medium_id ='$aid'";
		$result1=mysql_query($query1);
	}

	public function selecThemeById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT * FROM art_theme at, art_cat_theme act where at.theme_id=act.theme_id and act.cat_id='$cId'";
		error_log('theme   '.$query);
		$result=mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result))
		{
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;
	}

	public function getmediumById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT am.*, ac.*, a_t.* FROM art_cat_theme_medium actm, art_medium am, art_category ac, art_theme a_t WHERE am.medium_id = '$cId' AND actm.medium_id = am.medium_id AND actm.cat_id = ac.cat_id AND actm.theme_id = a_t.theme_id";
		error_log('hi   '.$query);
		$result=mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}

	public function mediumUpdate($post)
	{
		//var_dump($post);
		//die();
		$dbHandle = $this->init();
		$cid=$post['categoryID'];
		$tid=$post['themeID'];
		$aid=$post['mediumID'];
		$mediumname = $post['mediumName'];
		$update = "update art_medium set medium_name='".$mediumname."' where medium_id='$aid'";
		$updateresult = mysql_query($update);
		$delete = "DELETE FROM art_cat_theme_medium WHERE medium_id = '$aid'";
		$deleteResult = mysql_query($delete);
		$insert = "insert into art_cat_theme_medium (cat_id, theme_id, medium_id) values ($cid, $tid, $aid)";
		$insertResult = mysql_query($insert);
	}
	//////// --------artist  query start
	public function insertArtist($post)
	{
		$dbHandle=$this->init();
		$artistFname=$post['artistFname'];
		$artistMname=$post['artistMname'];
		$artistLname=$post['artistLname'];
		$education=$post['education'];
		$artistAds=$post['artistAds'];
		$city=$post['city'];
		$artistState=$post['artistState'];
		$artistCountry=$post['artistCountry'];
		$pin=$post['pin'];
		$mob=$post['mob'];
		$phone=$post['phone'];
		$Email=$post['Email'];
		$Ltime=$post['Ltime'];
		$area1=$post['area1'];
		$image = time().$post['file']["photo"]["name"];
		move_uploaded_file($post['file']["photo"]["tmp_name"], "public/images/artist_box".$image);
		$h1=" INSERT INTO art_artist ( fname, mname, lname, education,photo,address, city, state, country, pin, mobile, phone, email, lifetime, aboutus) VALUES ('$artistFname','$artistMname','$artistLname','$education','$image','$artistAds','$city','$artistState','$artistCountry','$pin','$mob','$phone','$Email','$Ltime','$area1')";
		error_log('ffffff '.$h1);
		$result=mysql_query($h1) or die(mysql_error());
		$artistID= mysql_insert_id();
		$area2=$post['area2'];
		$area3=$post['area3'];

		$h2="INSERT INTO art_artist_event (artist_id,event_name)VALUES('$artistID','$area2')";
		error_log('fffffflll '.$h2);
		$result1=mysql_query($h2) or die(mysql_error());
		$h3="INSERT INTO art_artist_awards (artist_id,award_name)VALUES('$artistID','$area3')";
		$result1=mysql_query($h3) or die(mysql_error());
		error_log('fffffflll '.$h3);
	}
	public function manageArtist()
	{
		$dbHandle = $this->init();
		$query = "select * from art_artist";
		$result = mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result)){
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;

	}
	public function deleteArtistById($aid)
	{
		$dbHandle=$this->init();
		$query="delete from art_artist where artist_id ='$aid'";
		$result=mysql_query($query);
		$query1="delete from art_artist_awards where artist_id ='$aid'";
		$result1=mysql_query($query1);
		$query2="delete from art_artist_event where artist_id ='$aid'";
		$result2=mysql_query($query2);

	}

	public function getartistById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT * FROM art_artist where artist_id='$cId'";
		error_log('hi   '.$query);
		$result=mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}
	public function getartisteventById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT * FROM art_artist_event where artist_id='$cId'";
		error_log('hi   '.$query);
		$result=mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}
	public function getartistawardById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT * FROM art_artist_awards where artist_id='$cId'";
		error_log('hi   '.$query);
		$result=mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}

	public function artistUpdate($post)
	{
		$dbHandle = $this->init();
		$aid=$post['artist_id'];
		$artistFname=$post['artistFname'];
		$artistMname=$post['artistMname'];
		$artistLname=$post['artistLname'];
		$education=$post['education'];
		$artistAds=$post['artistAds'];
		$city=$post['city'];
		$artistState=$post['artistState'];
		$artistCountry=$post['artistCountry'];
		$pin=$post['pin'];
		$mob=$post['mob'];
		$phone=$post['phone'];
		$Email=$post['Email'];
		$Ltime=$post['Ltime'];
		$area1=$post['area1'];
		$oldImg = $post['oldPhoto'];
		if($post['file']["updatepic"]["name"]!=''){
			$image = time().$post['file']["updatepic"]["name"];
			move_uploaded_file($post['file']["updatepic"]["tmp_name"], "public/images/artist_box".$image);
		}else{
			$image = $oldImg;
		}
		$update = "update art_artist set fname='".$artistFname."',mname='".$artistMname."',mname='".$artistMname."',lname='".$artistLname."',education='".$education."',photo='".$image."',address='".$artistAds."',city='".$city."',state='".$artistState."',country='".$artistCountry."',pin='".$pin."',mobile='".$mob."',phone='".$phone."',email='".$Email."',lifetime='".$Ltime."',aboutus='".$area1."' where artist_id='$aid'";
		$updateresult = mysql_query($update);
		error_log('hiiiiiiiiiiiiiiiii   '.$update);
	}
	public function artistEvent($post)
	{
		$dbHandle = $this->init();
		$aid=$post['artist_id'];
		$artistevent=$post['area2'];
		$update = "update art_artist_event set event_name='".$artistevent."'where artist_id='$aid'";
		$updateresult = mysql_query($update);
		error_log('hiiiiiiiiiiiiiiiii   '.$update);
			
	}
	public function artistAwards($post)
	{
		$dbHandle = $this->init();
		$aid=$post['artist_id'];
		$artistawards=$post['area3'];
		$update = "update art_artist_awards set award_name='".$artistawards."'where artist_id='$aid'";
		$updateresult = mysql_query($update);
		error_log('hiiiiiiiiiiiiiiiii   '.$update);

	}
	public function manageAwards()
	{
		$dbHandle = $this->init();
		$query = "select * from art_artist_awards";
		$result = mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result)){
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;

	}

	public function selecmediumById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT * FROM art_medium am, art_cat_theme_medium actm where am.medium_id=actm.medium_id and actm.theme_id='$cId'";
		error_log('hi   '.$query);
		$result=mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result))
		{
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;
	}


	public function insertGallery($post)
	{
		$dbHandle=$this->init();
		$name=$post['Gname'];
		$Gsize=$post['Gsize'];
		$Gprice=$post['Gprice'];
		$image = time().$post['file']["Gimage"]["name"];
		move_uploaded_file($post['file']["Gimage"]["tmp_name"], "public/images/".$image);
		$h1=" INSERT INTO `art_gallery` ( `gallery_name`, `gallery_image`,  `gallery_size`, `gallery_prize`,gallery_status ) VALUES ('$name', '$image', '$Gsize', '$Gprice','available')";
		error_log('ffffff '.$h1);
		$result=mysql_query($h1) or die(mysql_error());
		$galleryID= mysql_insert_id();
		$artistID=$post['artistID'];
		$categoryID=$post['categoryID'];
		$themeID=$post['themeID'];
		$mediumID=$post['mediumID'];
		$h2="INSERT INTO `art_gallery_mapping`(`artist_id`,`cat_id`,`theme_id`,`medium_id`,`Gallery_id` )VALUES('$artistID','$categoryID','$themeID','$mediumID','$galleryID')";
		error_log('fffffflll '.$h2);
		$result1=mysql_query($h2) or die(mysql_error());
	}
	public function manageGallery()
	{
		$dbHandle = $this->init();
		$query = "select * from art_gallery";
		$result = mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result)){
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;

	}

	public function deleteGalleryById($aid)
	{
		$dbHandle=$this->init();
		$query="delete from art_gallery where gallery_Id ='$aid'";
		$result=mysql_query($query);
		$query1="delete from   art_gallery_mapping where Gallery_id ='$aid'";
		$result1=mysql_query($query1);

	}
	public function getgallerytById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT * FROM art_gallery where gallery_Id='$cId'";
		error_log('hi   '.$query);
		$result=mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}
	public function getMappingid($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT *FROM art_gallery_mapping where Gallery_id='$cId'";
		error_log('hi   '.$query);
		$result=mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;

	}
	public function galleryUpdate($post)
	{
		$dbHandle = $this->init();
		$aid=$post['gallery_id'];
		$gName=$post['gName'];
		$Gsize=$post['Gsize'];
		$Gprice=$post['Gprice'];
		$oldImg = $post['oldPhoto'];
		if($post['file']["updatepic"]["name"]!=''){
			$image = time().$post['file']["updatepic"]["name"];
			move_uploaded_file($post['file']["updatepic"]["tmp_name"], "public/images/".$image);
		}else{
			$image = $oldImg;
		}
		$update = "update art_gallery set gallery_name='".$gName."',gallery_image='".$image."',gallery_size='".$Gsize."',gallery_prize='".$Gprice."' where gallery_Id='$aid'";
		$updateresult = mysql_query($update);
		error_log('hiiiiiiiiiiiiiiiii   '.$update);
	}

	public function galleryUpdatemap($post)
	{
		$dbHandle = $this->init();
		$aid=$post['gallery_id'];
		$artist_id=$post['artistID'];
		$cat_id=$post['categoryID'];
		$theme_id=$post['themeID'];
		$medium=$post['mediumID'];
		$update = "update art_gallery_mapping set artist_id='".$artist_id."', cat_id='".$cat_id."',theme_id='".$theme_id."',medium_id='".$medium."' where gallery_Id='$aid'";
		$updateresult = mysql_query($update);
		error_log('hiiiiiiiiiiiiiiiii   '.$update);

	}

	public function manageUser()
	{
		$dbHandle = $this->init();
		$query = "select * from art_user_details";
		$result = mysql_query($query);
		$resultArray = array();
		$i=0;
		while($row = mysql_fetch_assoc($result)){
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;

	}
	public function deleteUserById($aid)
	{
		$dbHandle=$this->init();
		$query="delete from art_user_details where user_Id ='$aid'";
		$result=mysql_query($query);
			
	}

	public function getUserById($cId)
	{
		$dbHandle=$this->init();
		$query="SELECT *FROM art_user_details where user_Id='$cId'";
		error_log('hi   '.$query);
		$result=mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;

	}
	public function userUpdate($post)
	{
		$dbHandle = $this->init();
		$aid=$post['user_id'];
		$userName=$post['userName'];
		$userAddress=$post['userAddress'];
		$City=$post['City'];
		$State=$post['State'];
		$Country=$post['Country'];
		$Email=$post['Email'];
		$user_name=$post['user_name'];
		$password=$post['password'];
		$Status=$post['Status'];
		$update = "update art_user_details set name='".$userName."',address='".$userAddress."',city='".$City."',state='".$State."',country='".$Country."',email='".$Email."',user_name='".$user_name."',pssword ='".$password."',status='".$Status."'where user_id='$aid'";
		$updateresult = mysql_query($update);
		error_log('hiiiiiiiiiiiiiiiii   '.$update);
		//	$update1 = "update Art_user_details set status='".$userStatus."' where user_id='$aid'";
		//$updateresult1 = mysql_query($update1);
	 	
	}


	//*****************Manage Event Start***************\\

	public function insertEvent($post) {
		$dbHandle = $this->init();
		$eventName = ucwords($post['eventName']);
		$eventAdd = ucwords($post['eventAdd']);
		$eventStartDate = $post['eventStartDate'];
		$eventEndDate = $post['eventEndDate'];
		$eventStartTime = $post['eventStarthour'] . ":" . $post['eventStartMinute'] . " " . $post['eventStartType'];
		$eventEndTime = $post['eventEndhour'] . ":" . $post['eventStartMinute'] . " " . $post['eventEndType'];
		$query = "INSERT INTO art_event (event_name,event_address,event_start_date,event_end_date,event_start_time,event_end_time,event_status)VALUES('$eventName','$eventAdd','$eventStartDate','$eventEndDate','$eventStartTime','$eventEndTime','Yes')";
		error_log('ffffff ' . $query);
		$result = mysql_query($query) or die(mysql_error());
	}

	public function managAllEvent() {
		$dbHandle = $this->init();
		$query = "select * from art_event";
		$result = mysql_query($query);
		$resultArray = array();
		$i = 0;
		while ($row = mysql_fetch_assoc($result)) {
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;
		//var_dump($result_array);
	}

	public function getEventById($eId) {

		$dbHandle = $this->init();
		$query = "SELECT * FROM art_event where event_id='$eId'";
		error_log('hi   ' . $query);
		$result = mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}

	public function updateEvent($post) {
		$dbHandle = $this->init();
		$eId = $post['eventId'];
		$eventName = ucwords($post['eventName']);
		$eventAdd = ucwords($post['eventAdd']);
		$eventStartDate = $post['eventStartDate'];
		$eventEndDate = $post['eventEndDate'];
		$eventStartTime = $post['eventStarthour'] . ":" . $post['eventStartMinute'] . " " . $post['eventStartType'];
		$eventEndTime = $post['eventEndhour'] . ":" . $post['eventStartMinute'] . " " . $post['eventEndtype'];
		$eventStatus = $post['eventStatus'];
		$update = "update art_event set event_name='" . $eventName . "',event_address='" . $eventAdd . "',event_start_date='" . $eventStartDate . "',event_end_date='" . $eventEndDate . "',event_start_time='" . $eventStartTime . "',event_end_time='" . $eventEndTime . "',event_status='" . $eventStatus . "' where event_id='$eId'";
		$updateresult = mysql_query($update);
	}

	public function deleteEventById($eId) {
		$dbHandle = $this->init();
		$query = "delete from art_event where event_id ='$eId'";
		$result = mysql_query($query);
	}

	//*****************Manage Event End***************\\
	//*********************Manage CMS Start********************************\\
	public function insertCms($post) {
		$dbHandle = $this->init();
		$title = $post['title'];
		$content = $post['area2'];
		$pageTitle = $post['pageTitle'];
		$metaData = $post['metaData'];
		$pageDescription = $post['pageDescription'];
		$pageKeywords = $post['pageKeywords'];
		$setcms = "INSERT INTO cms (title,content,pageTitle,pageMetaData,pageKeywords,pageDescription,status,dateCreated,site)VALUES('$title','$content','$pageTitle','$metaData','$pageKeywords','$pageDescription','Active',CURDATE(),'artdex')";
		//error_log('kjgh  '.$hset);
		$result = mysql_query($setcms) or die(mysql_error());
		return $result;
	}

	public function getAllCms() {
		$dbHandle = $this->init();
		$query = "select * from cms";
		$result = mysql_query($query);
		$resultArray = array();
		$i = 0;
		while ($row = mysql_fetch_assoc($result)) {
			$resultArray[$i] = $row;
			$i++;
		}
		return $resultArray;
	}

	public function CmsDetailByID($aId) {
		$dbHandle = $this->init();
		$query = "select * from cms where cmsID='$aId' ";
		//error_log('kjgh  '.$query);
		$result = mysql_query($query);
		$resultArray = mysql_fetch_assoc($result);
		return $resultArray;
	}

	public function updateCmsById($post) {
		//var_dump($post);
		$dbHandle = $this->init();
		$aid = trim($post['cmsId']);
		$title = trim($post['title']);
		$content = trim($post['area2']);
		$pageTitle = trim($post['pageTitle']);
		$status = trim($post["status"]);
		$pageMetaData=trim($post['metaData']);
		//$dateCreated = $post['dateCreated'];
		$pageKeywords = trim($post['pageKeywords']);
		$pageDescription = trim($post['pageDescription']);
		$update = "update cms set title='" . $title . "',content='" . $content . "',pageTitle='" . $pageTitle . "',status='" . $status . "',pageMetaData='" . $pageMetaData . "',pageKeywords='" . $pageKeywords . "',pageDescription='" . $pageDescription . "' where cmsID = '$aid'";
		//error_log('hi error is     '.$update);
		$updateresult = mysql_query($update);
		//error_log('hhh  '.$update);
	}

	//*********************Manage CMS End********************************\\


}






